import 'package:flutter/material.dart';

/// Basic layout for indicating that an exception occurred.
class BtFirstPageExceptionIndicator extends StatelessWidget {
  const BtFirstPageExceptionIndicator({
    this.message,
    this.onTryAgain,
    Key? key,
  }) : super(key: key);

  final String? message;
  final VoidCallback? onTryAgain;

  @override
  Widget build(BuildContext context) {
    final message = this.message;
    //
    return Center(
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Image.asset(
            'assets/images/bt_icon_no_data.png',
            width: 198,
            height: 218,
          ),
          if (message != null)
            const SizedBox(
              height: 10,
            ),
          if (message != null)
            Text(message,
                textAlign: TextAlign.center,
                style: const TextStyle(
                  fontSize: 14,
                  decoration: TextDecoration.none,
                )),
          if (onTryAgain != null)
            const SizedBox(
              height: 15,
            ),
          if (onTryAgain != null)
            SizedBox(
              height: 35,
              width: 110,
              child: FloatingActionButton.extended(
                onPressed: onTryAgain,
                label: const Text("Reload"),
                icon: const Icon(
                  Icons.refresh,
                  color: Colors.white,
                ),
              ),
            ),
          if (onTryAgain != null)
            const SizedBox(
              height: 100,
            ),
        ],
      ),
    );
  }
}
